<?php

namespace app\service\impl;

use app\repository\CategoryRepository;
use app\service\CategoryService;
use app\support\ListContainer;
use DI\Attribute\Inject;
use Illuminate\Database\Eloquent\Collection;
use think\helper\Arr;

class CategoryServiceImpl implements CategoryService
{
    #[Inject]
    protected CategoryRepository $categoryRepository;
    public function listOf(array $categoryPageQueryDTO): ListContainer
    {
        $categorys = $this->categoryRepository->listOf($categoryPageQueryDTO);
        return new ListContainer($categorys);
    }

    public function save(array $categoryDTO): void
    {
        $this->categoryRepository->save($categoryDTO);
    }

    public function deleteById(int $id): void
    {
        $this->categoryRepository->deleteById($id);
    }

    public function update(array $categoryDTO): void
    {
        $this->categoryRepository->update($categoryDTO);
    }

    public function startOrStop(string $status, int $id): void
    {
        $this->categoryRepository->startOrStop($status, $id);
    }

    public function getListByType($type=1): array
    {
        return $this->categoryRepository->getListByType($type);
    }
}